<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="point">
  <link rel="stylesheet" href="./assets/common.css">
  <title>Scatter Plot</title>
</head>

<body>
  <div id="canvas"></div>
  <script src="./assets/jquery-3.2.1.min.js"></script>
  <script src="./assets/data-set.min.js"></script>
  <script src="../build/g2.js"></script>
  <script>
    $.getJSON('./data/scatter.json', data => {
      const ds = new DataSet();
      const dv = ds.createView('demo').source(data);

      const chart = new G2.Chart({
        container: 'canvas',
        forceFit: true,
        height: window.innerHeight
      });
      chart.source(dv);
      chart.scale({
        weight: {
          alias: '体重（kg）'
        },
        height: {
          alias: '身高（cm）'
        }
      });
      chart.point() // scatter plot
        .position('height*weight')
        .color('gender', [ 'rgba(223, 83, 83, 0.7)', 'rgba(119, 152, 191, 0.7)' ])
        .shape('gender', [ 'circle', 'diamond' ])
        .size(6);
      chart.render();
    });
  </script>
</body>

</html>
